<?

require_once ("application.list.inc");

global $_GLOBAL_DBH;
global $_OBJECT_IFACE_PANEL;

$indexes = array (
	title=>array (label=>"Title",order=>"DEFAULT",wrapper=>"vmc_icon_task"),
	project_title=>array (label=>"Project",order=>"DEFAULT",wrapper=>"vmc_icon_project"),
	total_time=>array (label=>"Total Time",order=>"DEFAULT",wrapper=>"vmc_icon_total_time"),
	status=>array (label=>"Status",order=>"DEFAULT",
			values=>array (
				"active"=>"Active",
				"inactive"=>"Inactive",
				"hold"=>"Hold",
				"suspended"=>"Suspended",
				"processing"=>"Processing",
				"new"=>"New",
				"assigned"=>"Assigned",
				"started"=>"Started",
				"stopped"=>"Stopped",
				"complete"=>"Complete",
			)),
	date_due=>array (label=>"Date Due",order=>"DEFAULT",wrapper=>"vmc_icon_date"),
	cdate=>array (label=>"Create Date",order=>"DEFAULT",wrapper=>"vmc_icon_date"),
);

$object_ctl = "/admin/projects/projects/fs_projects.php?fs_action=view&fs_tab=tasks&fs_tab_option=fs_tasks&";
$link_options = "&fs_action=view&fs_tab=working_tasks&user_id={$_REQUEST["user_id"]}";
$list_options = array ();

$_OBJECT_IFACE_LIST = _app_create_list_object (array (
                db_conn=>$_GLOBAL_DBH,
                indexes=>$indexes,
		list_count=>"SELECT COUNT(*) FROM project_task_timer WHERE user_id={$_REQUEST["user_id"]} AND date_end='' GROUP BY task_id",
		list_select=>"SELECT project_tasks.*,projects.title AS project_title,CONCAT(task_id,'&project_id=',project_id,'&') AS target,

			(SELECT SEC_TO_TIME(SUM(
					CASE project_task_timer.date_end
						WHEN '' THEN UNIX_TIMESTAMP()
						ELSE UNIX_TIMESTAMP(project_task_timer.date_end)
					END - UNIX_TIMESTAMP(project_task_timer.date_begin)))
				FROM project_task_timer
				WHERE task_id=project_tasks.id)
			AS total_time
		FROM project_task_timer,project_tasks,projects WHERE project_task_timer.user_id={$_REQUEST["user_id"]} AND project_task_timer.date_end='' AND project_task_timer.task_id=project_tasks.id AND project_tasks.project_id=projects.id GROUP BY project_task_timer.task_id",
                list_id=>"lc_user_working_tasks",
                list_options=>$list_options,
                primary_key=>"target",
                primary_relation=>"task_id",
                link_options=>$link_options,
                object_ctl=>$object_ctl
));

$_OBJECT_IFACE_TABBING_PANEL->insert_container ($_OBJECT_IFACE_LIST);

?>
